#ifndef MYGLWIDGET_H
#define MYGLWIDGET_H

#include <QtOpenGL/QtOpenGL>
#include <QtOpenGL/qgl.h>
#include <QtOpenGL/QGLWidget>
#include "ply.h"
#include <QImage>



class myGLWidget : public QGLWidget
{
    Q_OBJECT
public:
    myGLWidget(QWidget* parent,QString filename);
    ~myGLWidget();
    void setTexDir(QString str)
    {
        texDir=str;
    }
    QSize minimumSizeHint() const;
    QSize sizeHint() const;
    ply *myply;
    int frameIndex;
    float offset_x;
    float offset_y;
    float offset_z;
    bool fullscreen;

public slots:
    void setXRotation(int angle);
    void setYRotation(int angle);
    void setZRotation(int angle);

signals:
    void xRotationChanged(int angle);
    void yRotationChanged(int angle);
    void zRotationChanged(int angle);
	
protected:
    void initializeGL();      //初始化调用的
    void resizeGL(int w, int h);          //窗口大小改变调用的
    void paintGL();                     //更新时调用的
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void wheelEvent(QWheelEvent *e);
    int xRot, yRot, zRot;

    GLfloat triangle_rotate;
    void timerEvent(QTimerEvent *event);   //控制图形旋转
    modelspace::mpoint *pp;
    modelspace::face *face;
    int facenum;
    int pointnum;
    float scalednum;

    GLuint texture[40];
    void loadGLTextures();

    QImage texImage[40];
    int weiliNum;    //纹理数量
    QString texDir;
    QColor qtPurple;
    QPoint lastPos;
};


#endif // MYGLWIDGET_H
